package largemodel

import (
	"context"
	"github.com/jinzhu/copier"
	"go.mongodb.org/mongo-driver/bson/primitive"
	model "large-model-platform-backend/mongo"

	"large-model-platform-backend/internal/svc"
	"large-model-platform-backend/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateLogic {
	return &UpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdateLogic) Update(req *types.LargeModelUpdateReq) (resp *types.BooleanResp, err error) {
	largemodel := l.svcCtx.LargeModel
	hex, err := primitive.ObjectIDFromHex(req.ID)
	largeModel1 := model.LargeModel{}
	copier.Copy(&largeModel1, req)
	largeModel1.ID = hex
	//largeModel1 := model.LargeModel{
	//	ID:       hex,
	//	Type:     req.Type,
	//	NickName: req.NickName,
	//	Number:   req.Number,
	//	DeepSeek: model.IDeepSeek{},
	//	KiMi:     model.IKiMi{},
	//}
	err = largemodel.UpdateOther(l.ctx, req.ID, &largeModel1)

	return &types.BooleanResp{
		Result: types.Result{
			Code:      200,
			Message:   "",
			ExtInfo:   "",
			Timestamp: 0,
		},
		Data: true,
	}, nil
}
